const {
  unDefined,
  nullValue,
  emailver,
  passwordver,
} = require("@/utils/valiData");
const result = require("@/utils/handle");
// 分析游记关键词
const ArticleKeyword = (text) => {
  unDefined([text]);
};

// 注册管理员账号
const AdminRegister = (email, password) => {
  unDefined([email, password]);
  nullValue([
    { value: email, tips: "请输入邮箱" },
    { value: password, tips: "请输入密码" },
  ]);
  if (!emailver.test(email)) {
    throw new result("邮箱格式错误", 422);
  }
  if (!passwordver.test(password)) {
    throw new result("密码长度为6-20位，且必须包含数字和字母", 422);
  }
};

// 更新管理员头像，昵称
const ModifyUserInfor = (_id, avatarUrl, nickname) => {
  unDefined([_id, avatarUrl, nickname]);
  nullValue([
    { value: _id, tips: "请输入管理员ID" },
    { value: avatarUrl, tips: "请上传头像" },
    { value: nickname, tips: "请输入昵称" },
  ]);
};

// 上传每日推荐
const DailyRecom = (imageUrl, title, address, color) => {
  unDefined([imageUrl, title, address, color]);
  nullValue([
    { value: imageUrl, tips: "请上传图片" },
    { value: title, tips: "请输入标题" },
    { value: address, tips: "请选择城市" },
    { value: color, tips: "请选择颜色" },
  ]);
};
// 搜索省市数据
const SearchTravel = (keywords) => {
    unDefined([keywords]);
  }
  // 获取每日推荐
const Resreturn = (page) => {
  unDefined([page]);
  nullValue([
    { value: page, tips: "请输入页码" },
  ]);
}

// 删除每日推荐
const CompanionDetails = (_id) => {
  unDefined([_id]);
  nullValue([
    { value: _id, tips: "请输入_id" },
  ]);
}
// 提交四个推荐
const UploadFourTravel = (imageUrl,travel_id) => {
  unDefined([imageUrl,travel_id]);
  nullValue([
    { value: imageUrl, tips: "请上传封面图" },
    { value: travel_id, tips: "请输入游记_id" },
  ]);
}

// 修改更新四个游记
const ModifyRecomTravel = (_id,imageUrl,travel_id) => {
  unDefined([_id,imageUrl,travel_id]);
  nullValue([
    { value: _id, tips: "请输入_id" },
    { value: imageUrl, tips: "请上传封面图" },
    { value: travel_id, tips: "请输入游记_id" },
  ])
}

module.exports = {
  AdminRegister,
  ModifyUserInfor,
  DailyRecom,
  SearchTravel,
  Resreturn,
  CompanionDetails,
  UploadFourTravel,
  ModifyRecomTravel
};
